{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('../../python')\n",
    "import caffe\n",
    "import io\n",
    "from PIL import Image\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import scipy.misc\n",
    "import time\n",
    "import pdb\n",
    "import glob\n",
    "import pickle as pkl\n",
    "import random\n",
    "import h5py\n",
    "from multiprocessing import Pool\n",
    "from threading import Thread\n",
    "import skimage.io\n",
    "import copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train001\n",
      "Train002\n",
      "Train003\n",
      "Train004\n",
      "Train005\n",
      "Train006\n",
      "Train007\n",
      "['Train001', 'Train002', 'Train003', 'Train004', 'Train005', 'Train006', 'Train007']\n"
     ]
    }
   ],
   "source": [
    "file_path = 'ucsdPed1_image.txt' \n",
    "random.seed(10)\n",
    "f = open(file_path,'r')\n",
    "f_lines = f.readlines()\n",
    "f.close()\n",
    "video_dict = {}\n",
    "current_line = 0\n",
    "path_to_images = '/usr/not-backed-up/1_DATABASE/UCSD_Anomaly_Dataset.tar/UCSD_Anomaly_Dataset.v1p2/UCSDped1/Train/'\n",
    "# print(path_to_images)\n",
    "video_order = []\n",
    "for ix, line in enumerate(f_lines):\n",
    "    video = line.split(' ')[0].split('/')[1]  \n",
    "    print(video) # add anything in the end of each line -> keep [0] will remove \\n\n",
    "    frames = glob.glob('%s%s/*.tif' %(path_to_images, video))\n",
    "    num_frames = len(frames)  \n",
    "    video_dict[video]={}\n",
    "#     video_dict[video]['frames'] = frames[0].split('.')[0] + '.%04d.tif'\n",
    "#     a = frames[0].split('.')[0] + '.%04d.tif'\n",
    "#     print(a)\n",
    "#     print(num_frames)\n",
    "    video_order.append(video)\n",
    "#     input(\"pause\")\n",
    "print(video_order)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n"
     ]
    }
   ],
   "source": [
    "a = glob.glob('/usr/not-backed-up/1_DATABASE/UCSD_Anomaly_Dataset.tar/UCSD_Anomaly_Dataset.v1p2/UCSDped1/Train/Train001/*.tif')\n",
    "print(len(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "idx_list = range(0,7)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
